<template>
  <div>
    <TopFilter
      ref="searchOrdersPanel"
      :list="searchOrdersList"
      :cols="4"
      :rows="2"
      :labelWidth="70"
      :isSubmitBtn="true"
      @filterChange="changeHandle"
    />
    <!-- <div
      :style="{
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button type="primary" @click="queryData">查 询</el-button>
      <el-button @click="reset">重 置</el-button>
    </div>-->

    <div>
      <!-- 采购入库 -->
      <PartInventoryTable
        v-if="this.InAndOutTypes.showPartInventoryTable"
        ref="partInventoryTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 借进入库 -->
      <AdjustInventoryTable
        v-if="this.InAndOutTypes.showAdjustInventoryTable"
        ref="adjustInventoryTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :userItems="userItems"
        :tax="tax"
      />
      <!-- 配件报溢 -->
      <PartOverflowTable
        v-if="this.InAndOutTypes.showPartOverflowTable"
        ref="aartOverflowTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :tax="tax"
      />
      <!-- 维修领料 -->
      <RepairDispatchTable
        v-if="this.InAndOutTypes.showRepairDispatchTable"
        ref="RepairDispatchTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 配件销售 -->
      <PartSalesTable
        v-if="this.InAndOutTypes.showPartSalesTable"
        ref="PartSalesTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 内部领用 -->
      <InternalReceiveTable
        v-if="this.InAndOutTypes.showInternalReceiveTable"
        ref="InternalReceiveTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 借出出库 -->
      <AdjustOutboundTable
        v-if="this.InAndOutTypes.showAdjustOutboundTable"
        ref="AdjustOutboundTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 还出出库 -->
      <AlsojustOutboundTable
        v-if="this.InAndOutTypes.showAlsojustOutboundTable"
        ref="AlsojustOutboundTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 配件报损 -->
      <PartBreakTable
        v-if="this.InAndOutTypes.showPartBreakTable"
        ref="PartBreakTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :tax="tax"
      />
      <!-- 成本价调整入库 -->
      <CostAdjustInTable
        v-if="this.InAndOutTypes.showCostAdjustInTable"
        ref="CostAdjustInTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 成本价调整出库 -->
      <CostAdjustOutTable
        v-if="this.InAndOutTypes.showCostAdjustOutTable"
        ref="CostAdjustOutTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
      />
      <!-- 配件调拨处理 -->
      <StockRemovalTable
        v-if="this.InAndOutTypes.showStockRemovalTable"
        ref="StockRemovalTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :tax="tax"
      />
      <!-- 出库单 -->
      <reportOutboundTable
        v-if="this.InAndOutTypes.showReportOutboundTable"
        ref="reportOutboundTable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :tax="tax"
      />
      <!-- 入库单 -->
      <reportInventorytable
        v-if="this.InAndOutTypes.showReportInventorytable"
        ref="reportInventorytable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :tax="tax"
      />
      <!-- 还入入库 -->
      <returnToStorageTable
        v-if="this.InAndOutTypes.showReturnToStorageTable"
        ref="reportInventorytable"
        :fetchParamObj="fetchParamObj"
        :userList="userList"
        :tax="tax"
      />
    </div>
  </div>
</template>

<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import PartInventoryTable from './tables/partInventoryTable'; // 采购入库
import AdjustInventoryTable from './tables/adjustInventoryTable'; // 调拨入库
import PartOverflowTable from './tables/partOverflowTable'; // 配件报溢
import RepairDispatchTable from './tables/repairDispatchTable'; // 维修发料
import PartSalesTable from './tables/partSalesTable'; // 维修发料
import InternalReceiveTable from './tables/internalReceiveTable'; // 内部领用
import AdjustOutboundTable from './tables/adjustOutboundTable'; // 调拨出库
import AlsojustOutboundTable from './tables/alsojustOutboundTable'; // 还出出库
import PartBreakTable from './tables/partBreakTable'; // 配件报损
import CostAdjustInTable from './tables/costAdjustInTable'; // 成本价调整入库
import CostAdjustOutTable from './tables/costAdjustOutTable'; // 成本价调整出库
import StockRemovalTable from './tables/stockRemovalTable'; // 配件移库
import reportOutboundTable from './tables/reportOutboundTable'; // 出库单
import reportInventorytable from './tables/reportInventoryTable'; // 入库单
import returnToStorageTable from './tables/returnToStorageTable'; // 还入入库单
import { getStroageList } from '@/api/part/partOutbound/partBreak';
import { getAllUser, queryTex } from '@/api/part/common';

export default {
  name: 'vehiclesDaily',
  components: {
    PartInventoryTable, // 采购入库
    AdjustInventoryTable, // 调拨入库
    PartOverflowTable,
    RepairDispatchTable,
    PartSalesTable,
    InternalReceiveTable, // 内部领用
    AdjustOutboundTable, // 调拨出库
    AlsojustOutboundTable, // 还出出库
    PartBreakTable, // 配件报损
    CostAdjustInTable, // 成本价调整入库
    CostAdjustOutTable, // 成本价调整出库
    StockRemovalTable, // 配件移库
    reportOutboundTable, // 出库单
    reportInventorytable, // 入库单
    returnToStorageTable // 还入入库
  },
  mixins: [dictionary],
  data() {
    this.arrayTypes = ['MULTIPLE_SELECT'];
    return {
      searchOrdersList: this.createSearchOrdersList(),
      onChangeColumn: [],
      fetchParamObj: null,
      InAndOutTypes: {
        // showDefaultTable: false, //  默认表格
        showPartInventoryTable: true, // 采购入库表格
        showAdjustInventoryTable: false, // 调拨入库表格
        showPartOverflowTable: false, // 配件报溢表格
        showRepairDispatchTable: false, // 维修发料表格
        showPartSalesTable: false, // 配件销售表格
        showInternalReceiveTable: false, // 内部领用表格
        showAdjustOutboundTable: false, // 调拨出库表格
        showAlsojustOutboundTable: false, // 还出出库表格
        showPartBreakTable: false, // 配件报损表格
        showCostAdjustInTable: false, // 成本价调整入库表格
        showCostAdjustOutTable: false, // 成本价调整出库表格
        showStockRemovalTable: false, // 配件移库表格
        showReportOutboundTable: false, // 出库单
        showReportInventorytable: false, // 入库单
        showReturnToStorageTable: false // 还入入库
        // 采购入库、调拨入库、配件报溢、维修发料、配件销售、内部领用、调拨出库、
        // 配件报损、成本价调整入库、成本价调整出库、配件移库
      },
      userList: [], // 人员列表
      tax: 0, // 税率
      userItems: []
    };
  },

  computed: {
    ptype() {
      return this.$route.meta.ptype;
    } // 模块区分
  },
  watch: {},
  mounted() {
    this.getStorage();
    this.getAllUserList();
    // this.getTax();
    this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').initialValue = [
      moment()
        .startOf('month')
        .format('YYYY-MM-DD'),
      moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
    ];
  },
  methods: {
    async getTax() {
      if (!this.tax) {
        let res = await queryTex();
        this.tax = Number(res.data);
      }
    },
    // 获取所有员工
    async getAllUserList() {
      let res = await getAllUser();
      if (res.resultCode == 200) {
        res.data.map(e => {
          this.userList[e.userId] = e.employeeName;
        });
        this.userItems = res.data.map(e => ({ text: e.employeeName, value: e.userId }));
      } else [this.$notify.error({ title: '提示信息', message: '获取人员列表失败' })];
    },
    createSearchOrdersList() {
      return [
        {
          type: 'RANGE_DATE',
          // dateType: 'date',
          label: '日期',
          fieldName: 'finishedDateBegin|finishedDateEnd',
          initialValue: [
            moment()
              .startOf('month')
              .format('YYYY-MM-DD'),
            moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          ],
          valueFormat: 'yyyy-MM-dd',
          rules: [{ required: true, message: '选择日期', trigger: 'blur' }]
        },
        {
          type: 'RANGE_DATE',
          labelWidth: '120px',
          fieldName: 'dateBegin|dateEnd',
          placeholder: '选择日期',
          hidden: true,
          labelOptions: {
            fieldName: 'dateType',
            initialValue: 'out',
            itemList: [
              { text: '出库日期', value: 'out' },
              { text: '结算日期', value: 'squareUp' }
              // { text: '结清日期', value: 'squareUp' },
            ]
          },
          rules: [{ required: true, message: '选择日期', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '单据类型',
          fieldName: 'queryType',
          // placeholder: '请选择',
          clearable: false,
          itemList: this.createInAndOutType(),
          initialValue: 12151001,
          change: val => {
            this.createTableColumns(val);
          },
          rules: [{ required: true, message: '请输入单据类型', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '单据号码',
          fieldName: 'billNo'
          // placeholder: '请输入单据号码'
        },
        {
          type: 'RADIO',
          label: '类型区分',
          fieldName: 'allocateType',
          initialValue: '82121001',
          itemList: [
            { text: '借进入库', value: '82121001' },
            { text: '还入入库', value: '82121002' }
          ],
          placeholder: '',
          hidden: true
          // rules: [{ required: true, message: '请选择出库日期', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '仓库',
          fieldName: 'storageCode',
          // placeholder: '请选择',
          itemList: []
        },
        {
          type: 'INPUT',
          label: '主组号',
          fieldName: 'mainGroupNo',
          hidden: true
        },
        {
          type: 'INPUT',
          label: '配件代码',
          fieldName: 'partNo'
          // placeholder: '请输入配件代码',
          // hidden: true
        },
        {
          type: 'INPUT',
          label: '工单号',
          fieldName: 'roNo',
          // placeholder: '请输入工单号',
          hidden: true
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'license',
          // placeholder: '请输入车牌号',
          hidden: true
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          // placeholder: '请输入VIN',
          hidden: true
        },

        // {
        //   type: 'INPUT',
        //   label: '配件说明',
        //   fieldName: 'partName',
        //   hidden: false
        // },
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'customerName',
          // placeholder: '请输入客户名称',
          hidden: true
        },
        {
          type: 'INPUT',
          label: '备注',
          fieldName: 'remake',
          // placeholder: '请输入客户名称',
          hidden: true
        }
      ];
    },
    createInAndOutType() {
      return [
        // 采购入库、调拨入库、配件报溢、维修发料、配件销售、内部领用、调拨出库、
        // 配件报损、成本价调整入库、成本价调整出库、配件移库
        {
          text: '采购入库',
          value: 12151001
        },
        // {
        //   text: '借进入库',
        //   value: 12151002
        // },
        // {
        //   text: '还入入库',
        //   value: 12151016
        // },
        {
          text: '配件报溢',
          value: 12151005
        },
        {
          text: '维修领料',
          value: 12151006
        },
        {
          text: '配件销售',
          value: 12151007
        },
        {
          text: '内部领用',
          value: 12151008
        },
        // {
        //   text: '借出出库',
        //   value: 12151009
        // },
        // {
        //   text: '还出出库',
        //   value: 12151017
        // },
        {
          text: '配件报损',
          value: 12151010
        },
        {
          text: '成本价调整入库',
          value: 12151011
        },
        {
          text: '成本价调整出库',
          value: 12151012
        },
        {
          text: '配件移库',
          value: 12151013
        },
        // {
        //   text: '出库单',
        //   value: 12151014
        // }
        // {
        //   text: '入库单',
        //   value: 12151015
        // },
      ];
    },
    createTableColumns(queryType) {
      this.showFormPanel(queryType);
      switch (queryType) {
        case 12151001:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showPartInventoryTable = true;
          }
          break;
        case 12151002:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showAdjustInventoryTable = true;
          }
          break;
        case 12151005:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showPartOverflowTable = true;
          }
          break;
        case 12151006:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showRepairDispatchTable = true;
          }
          break;
        case 12151007:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showPartSalesTable = true;
          }
          break;
        case 12151008:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showInternalReceiveTable = true;
          }
          break;
        case 12151009:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showAdjustOutboundTable = true;
          }
          break;
        case 12151017:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showAlsojustOutboundTable = true;
          }
          break;
        case 12151010:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showPartBreakTable = true;
          }
          break;
        case 12151011:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showCostAdjustInTable = true;
          }
          break;
        case 12151012:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showCostAdjustOutTable = true;
          }
          break;
        case 12151013:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showStockRemovalTable = true;
          }
          break;
        case 12151014:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showReportOutboundTable = true;
          }
          break;
        case 12151015:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showReportInventorytable = true;
          }
          break;
        case 12151016:
          for (let key in this.InAndOutTypes) {
            this.InAndOutTypes[key] = false;
          }
          if (this.InAndOutTypes != 'undefined') {
            this.InAndOutTypes.showReturnToStorageTable = true;
          }
          break;
      }
    },

    // 获取仓库
    async getStorage() {
      const res = await getStroageList();
      this.searchOrdersList.find(x => x.fieldName === 'storageCode').itemList = res.data.map(x => ({
        text: x.STORAGE_NAME,
        value: x.STORAGE_CODE + ''
      }));
    },

    showFormPanel(queryType) {
      console.log(queryType, 'queryType---');
      this.searchOrdersList.find(x => x.fieldName === 'queryType').initialValue = queryType;
      if (queryType === 12151006) {
        // console.log(11111);
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = false;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = false;
        this.searchOrdersList = [...this.searchOrdersList];
      } else if (queryType === 12151007) {
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList = [...this.searchOrdersList];
        this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true;
      } else if (queryType === 12151011 || queryType === 12151012) {
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList = [...this.searchOrdersList];
        this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true;
      } else if (queryType === 12151002) {
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'allocateType').initialValue = '82121001';
        // this.searchOrdersList.find(x => x.fieldName === 'allocateType').itemList = [
        //   { text: '借进入库', value: '82121001' },
        //   { text: '还入入库', value: '82121002' }
        // ],
        this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true;
        this.searchOrdersList = [...this.searchOrdersList];
      } else if (queryType === 12151009) {
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').initialValue = '82121003';
        (this.searchOrdersList.find(x => x.fieldName === 'allocateType').itemList = [
          { text: '借出出库', value: '82121003' },
          { text: '还出出库', value: '82121004' }
        ]),
          (this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true);
        this.searchOrdersList = [...this.searchOrdersList];
      } else if (queryType === 12151017) {
        // 还出出库
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').initialValue = '82121003';
        (this.searchOrdersList.find(x => x.fieldName === 'allocateType').itemList = [
          { text: '借出出库', value: '82121003' },
          { text: '还出出库', value: '82121004' }
        ]),
          (this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true);
        this.searchOrdersList = [...this.searchOrdersList];
      } else if (queryType === 12151001) {
        // 采购入库
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true;
        this.searchOrdersList = [...this.searchOrdersList];
      } else {
        this.searchOrdersList.find(x => x.fieldName === 'finishedDateBegin|finishedDateEnd').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'roNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'license').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'vin').hidden = true;
        // this.searchOrdersList.find(x => x.fieldName === 'partNo').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'customerName').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'remake').hidden = false;
        this.searchOrdersList.find(x => x.fieldName === 'allocateType').hidden = true;
        this.searchOrdersList.find(x => x.fieldName === 'dateBegin|dateEnd').hidden = true;
        this.searchOrdersList = [...this.searchOrdersList];
      }
    },

    async getReceiveDetail(id) {
      const res = await getReceiveDetail(id);
      // console.log(res,'结清')
      this.showWriteOff = true;
      this.$nextTick(() => {
        this.$refs.writeOff.openModel(this.onChangeColumn, res.data);
      });
    },
    changeHandle(val) {
      console.log(val);
      val.finishedDateBegin = val.finishedDateBegin ? val.finishedDateBegin.split(' ')[0] + ' 00:00:00' : '';
      val.finishedDateEnd = val.finishedDateEnd ? val.finishedDateEnd.split(' ')[0] + ' 23:59:59' : '';
      val.dateBegin = val.dateBegin ? val.dateBegin.split(' ')[0] : '';
      val.dateEnd = val.dateEnd ? val.dateEnd.split(' ')[0] + ' 23:59:59' : '';
      if (val.finishedDateBegin || val.finishedDateEnd) {
        let diffMonth = moment(val.finishedDateEnd).diff(moment(val.finishedDateBegin), 'months');
        if (diffMonth > 5) return this.$notify.warning({ title: '提示信息', message: '起止日期跨度不能超过半年' });
      }
      // dateBegin|dateEnd
      if (val.dateBegin || val.dateEnd) {
        let diffMonth1 = moment(val.dateEnd).diff(moment(val.dateBegin), 'months');
        if (diffMonth1 > 5) return this.$notify.warning({ title: '提示信息', message: '起止日期跨度不能超过半年' });
      }
      this.fetchParamObj = Object.assign({}, val, { ptype: this.ptype ? this.ptype : null });
      this.fetchParamObj = { ...this.fetchParamObj };
    },

    queryData() {
      this.$refs.searchOrdersPanel.SUBMIT_FORM();
    },

    reset() {
      this.$refs.searchOrdersPanel.RESET_FORM();
    }
  }
};
</script>

<style lang="less">
.btn {
  text-align: center;
}
